package com.jiahe.video.config;

import ai.onnxruntime.OrtException;
import com.jiahe.video.ai.base.Onnx;
import com.jiahe.video.ai.YoloV7;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

@Configuration
public class OnnxConfig {

    @Resource
    private AppConfig appConfig;

    //static String model_path = "src/main/resources/model/yolov7-tiny.onnx";
    //String model_path;

    static String[] names = {
            "person", "bicycle", "car", "motorcycle", "airplane", "bus", "train",
            "truck", "boat", "traffic light", "fire hydrant", "stop sign", "parking meter",
            "bench", "bird", "cat", "dog", "horse", "sheep", "cow", "elephant", "bear",
            "zebra", "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase",
            "frisbee", "skis", "snowboard", "sports ball", "kite", "baseball bat",
            "baseball glove", "skateboard", "surfboard", "tennis racket", "bottle",
            "wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple",
            "sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza", "donut",
            "cake", "chair", "couch", "potted plant", "bed", "dining table", "toilet",
            "tv", "laptop", "mouse", "remote", "keyboard", "cell phone", "microwave",
            "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase", "scissors",
            "teddy bear", "hair drier", "toothbrush"};

    @Bean
    public Onnx yoloV7() throws OrtException {
        // 这个方法会在Spring启动时被调用一次，创建并返回Onnx实例
        return new YoloV7(names, appConfig.getModelPath(),false);
    }


}
